package cn.schoolwow.quickdao.module.database.ddl.common.flow;

import cn.schoolwow.quickdao.module.database.parent.domain.ResultSetConsumer;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

import java.sql.ResultSet;
import java.sql.SQLException;

public class SetHasResultSetFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        flowContext.putTemporaryData("resultSetConsumer",new ResultSetConsumer() {
            @Override
            public void consumeResultSet(ResultSet resultSet) throws SQLException {
                if (resultSet.next()) {
                    flowContext.putData("hasResult", true);
                }else{
                    flowContext.putData("hasResult", false);
                }
            }
        });
    }

    @Override
    public String name() {
        return "设置检查结果集是否有值的逻辑";
    }
}
